'use strict';
module.exports = app => {
  const { STRING, INTEGER, TEXT } = app.Sequelize;
    const diagnosis =  app.model.define(
      'diagnosis',
      {
          id: {type: INTEGER, primaryKey: true, autoIncrement: true},
            user_id: INTEGER,
            image: STRING,
            color_id: INTEGER,
      },
      {
          tableName: 'diagnosis',
          timestamps: true, // 启用时间戳(createdAt, updatedAt)
          updatedAt: 'updated_time', // 不想要 updatedAt
          createdAt: 'create_time', // 想要  createdAt 但是希望名称叫做 created_at
      }
    );
    // diagnosis 用户得诊断记录
    diagnosis.associate = function() {
        app.model.Diagnosis.belongsTo(app.model.User, {foreignKey: 'user_id', targetKey: 'id'});
        // 颜色
        app.model.Diagnosis.belongsTo(app.model.Color, {foreignKey: 'color_id', targetKey: 'id'});
    }
    return diagnosis
};
